<?php

function sntl_link_to( $name, $node, $options = array() )
{
  $link = '<a href="' . sntl_url_for( $node ) . '"';
  foreach ( $options as $key => $value )
  {
    $link .= ' ' . $key . '="' . $value . '"';
  }
  $link .= '>' . $name . '</a>';
  return $link;
}

function sntl_url_for( $node )
{
  $url = url_for( '@homepage' );
  $ancestors = $node->getAncestors();
  if ( $ancestors )
  {
    foreach ( $ancestors as $ancestor )
    {
      if ( $ancestor->getLevel() > 0 )
      {
        //sfContext::getInstance()->getLogger()->warning( $ancestor->getLevel() );
        $url .= $ancestor->getSlug() . '/';
      }
    }
  }
  $url .= $node->getRecord()->getSlug();
  return $url;
}